/**
 *====================================================
 * 文件名称: LogisticsCompanyCastor.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2015年10月16日			chenxy(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 */
package com.yuexunit.finance.member.action.v1.dto;

import org.apache.commons.lang.BooleanUtils;

import com.yuexunit.core.BusinessException;
import com.yuexunit.finance.common.util.BeanUtils;
import com.yuexunit.finance.member.action.v1.model.LogisticsCompanyDetail;
import com.yuexunit.finance.member.action.v1.model.LogisticsCompanyInfo;
import com.yuexunit.finance.member.entity.LogisticsCompanyEntity;

/**
 * @ClassName: LogisticsCompanyCastor
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年10月16日 下午11:17:29
 */
public class LogisticsCompanyCastor {

	public static LogisticsCompanyEntity fromLogisticsCompanyInfo(LogisticsCompanyInfo info, String... ignores) {
		try {
			LogisticsCompanyEntity entity = new LogisticsCompanyEntity();
			BeanUtils.copyProperties(info, entity, ignores);
			entity.setReportedState(BooleanUtils.toBoolean(info.getReportState()));
			entity.setEffective(BooleanUtils.toBoolean(info.getEffective()));
			return entity;
		} catch (Exception e) {
			e.printStackTrace();
			throw new BusinessException("物流公司信息生成失败");
		}
	}

	public static LogisticsCompanyDetail toLogisticsCompanyDetail(LogisticsCompanyEntity entity) {
		try {
			LogisticsCompanyDetail detail = new LogisticsCompanyDetail();
			BeanUtils.copyProperties(entity, detail);
			detail.setReportState(BooleanUtils.toIntegerObject(entity.getReportedState()));
			detail.setEffective(BooleanUtils.toIntegerObject(entity.getEffective()));
			return detail;
		} catch (Exception e) {
			e.printStackTrace();
			throw new BusinessException("物流公司信息生成失败");
		}
	}

}
